import { FC } from 'react'
import { Navigate } from 'react-router-dom';
// interface IAuthRouteProps extends JSX.ElementChildrenAttribute {
interface IAuthRouteProps {
  title: string | undefined,
  auth: boolean | undefined,
  children: any
}
const AuthRoute: FC<IAuthRouteProps> = ({ auth, title = '', children }) => { // 给默认值为空，保证一个类型
    document.title = title
  let node = (sessionStorage.getItem('token') && auth) || !auth ? children : <Navigate to='/login' />
  return (<>{node}</>);
}
export default AuthRoute;